import { login } from "../../api/login";

const state = () => ({
  all: [],
});
const mutations = {
  increment(state) {
    // 变更状态
    state.count++;
  },
};
const actions = {
  Login({ commit }, userInfo) {
    console.log("loading...", userInfo);
    const username = userInfo.username;
    const password = userInfo.password;

    return new Promise((resolve, reject) => {
      login(username, password)
        .then((res) => {
          resolve();
        })
        .catch((err) => {
          reject(err);
        });
    });
  },
};

export default {
  namespaced: true,
  state,
  actions,
  mutations,
};
